package com.cxyjy;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.util.unit.DataSize;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.socket.config.annotation.EnableWebSocket;

import javax.servlet.MultipartConfigElement;
import java.io.IOException;

@EnableScheduling
@EnableWebSocket
@SpringBootApplication
public class AppDemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(AppDemoApplication.class, args);
    }

    @Bean
    public MultipartConfigElement multipartConfigElement() throws IOException {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //单个文件最大
        factory.setMaxFileSize(DataSize.parse("102400KB")); //KB,MB
        // 设置总上传数据总大小
        factory.setMaxRequestSize(DataSize.parse("1024000KB"));
        return factory.createMultipartConfig();

    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
